SLOPES = [
    (1, 1),
    (3, 1),
    (5, 1),
    (7, 1),
    (1, 2),
]

with open('input.txt') as file:
    trees = [line.strip() for line in file.readlines()]
    width = len(trees[0])

    result = 1

    for (dx, dy) in SLOPES:
        x, y = 0, 0
        count = 0

        while y < len(trees):
            if (trees[y][x]) == '#':
                count += 1
            x = (x + dx) % width
            y += dy
        
        result *= count
    
    print(result)